﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PhatPhucLoc.dao;
using PhatPhucLoc.model;

namespace PhatPhucLoc.view
{
    public partial class FormQuanLyNhanVien : Form
    {
        public FormQuanLyNhanVien()
        {
            InitializeComponent();
        }

        private void FormQuanLyNhanVien_Load(object sender, EventArgs e)
        {
            DataTable dt = ThanhVienDAO.GetAllThanhVien1();
            grvNhanvien.DataSource = dt;

            DataTable dt1 = RoleDAO.GetAll();
            cbbVaitro.DisplayMember = "ten";
            cbbVaitro.ValueMember = "id";
            cbbVaitro.DataSource = dt1;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            ThanhVienModel model = new ThanhVienModel();
            model.TenDangNhap = txtPassword.Text;
            model.MatKhau = txtUsername.Text;
            model.MaVaiTro = cbbVaitro.SelectedValue.ToString();

            if (ThanhVienDAO.Insert(model))
            {
                DataTable dt = ThanhVienDAO.GetAllThanhVien1();
                grvNhanvien.DataSource = dt;
            }
            else
                MessageBox.Show("");
        }

    }
}
